// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2005-5-8

#ifndef __APIHELP_H_GUARD__
#define __APIHELP_H_GUARD__

#pragma once

#include "tlhelp32.h"

namespace JoyGuard
{

//##ModelId=44C4B60E0280
class ApiHelp
{
public:
	//##ModelId=44C4B60E0281
    static HANDLE CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID);
	//##ModelId=44C4B60E0291
    static BOOL Module32First(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
	//##ModelId=44C4B60E0295
    static BOOL Module32Next(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
	//##ModelId=44C4B60E029F
    static BOOL Process32First(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
	//##ModelId=44C4B60E02A3
    static BOOL Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
	//##ModelId=44C4B60E02A7
    static BOOL ReadProcessMemory(
        IN HANDLE hProcess,
        IN LPCVOID lpBaseAddress,
        OUT LPVOID lpBuffer,
        IN SIZE_T nSize,
        OUT SIZE_T * lpNumberOfBytesRead);
	//##ModelId=44C4B60E02B5
    static BOOL WriteProcessMemory(
        IN HANDLE hProcess,
        IN LPVOID lpBaseAddress,
        IN LPCVOID lpBuffer,
        IN SIZE_T nSize,
        OUT SIZE_T * lpNumberOfBytesWritten);
	//##ModelId=44C4B60E02C3
    static HANDLE CreateThread(
        IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
        IN SIZE_T dwStackSize,
        IN LPTHREAD_START_ROUTINE lpStartAddress,
        IN LPVOID lpParameter,
        IN DWORD dwCreationFlags,
        OUT LPDWORD lpThreadId);
	//##ModelId=44C4B60E02D1
    static HANDLE OpenProcess(
        IN DWORD dwDesiredAccess,
        IN BOOL bInheritHandle,
        IN DWORD dwProcessId);
	//##ModelId=44C4B60E02D6
    static DWORD WaitForSingleObject(
        IN HANDLE hHandle,
        IN DWORD dwMilliseconds);
	//##ModelId=44C4B60E02E0
    static BOOL VirtualProtectEx(
        IN  HANDLE hProcess,
        IN  LPVOID lpAddress,
        IN  SIZE_T dwSize,
        IN  DWORD flNewProtect,
        OUT PDWORD lpflOldProtect);
};

} // namespace JoyGuard

#endif  // __APIHELP_H_GUARD__
